/**********************************************************************\

 Copyright 2012 Diggory Blake

 This file is part of klip-engine

 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.

\**********************************************************************/
#pragma once

class kActor;

#include "kbase.h"
#include "kmath.h"
#include "kcontroller.h"

class kActor : public kBase {
	friend class kController;
private:
	kMat3x3 _transform;
	mutable kMat3x3 _invTransform;
	mutable bool _invTransformReady;
	kController* _controller;
	void* _controllerData;
protected:
	mutable bool _hasTransformChanged;

	kActor();
	void setTransform(const kMat3x3& transform);
public:
	inline kController* getController() const {
		return _controller;
	}
	inline const kMat3x3& getTransform() const {
		return _transform;
	}
	inline const kMat3x3& getInvTransform() const {
		if (!_invTransformReady) {
			_invTransform = inverse(_transform);
			_invTransformReady = true;
		}

		return _invTransform;
	}
};
